/* GUI CONVERTED from rcsqscdl.p (converter v1.76) Wed May 29 12:00:58 2002 */
/* rcsqscdl.p -  CUSTOMER SEQUENCE SCHEDULE DETAIL DELETE UTILITY             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8 $                                                           */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 9.1          CREATED: 11/15/99     BY: *N003* Patrick Rowan      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Revision: 1.6       BY: John Corda         DATE: 07/03/01  ECO: *N106*     */
/* Revision: 1.7       BY: Katie Hilbert      DATE: 04/15/02  ECO: *P03J*     */
/* $Revision: 1.8 $      BY: Katie Hilbert      DATE: 05/16/02  ECO: *P06T*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/*!
 ----------------------------------------------------------------------------
 DESCRIPTION: This program deletes detail records from the Customer Sequence
              Schedule.  Detail records (rcsd_det) are "marked" for delete
              in Seq. Schedule Maintenance, but are not physically deleted
              for audit reasons.
              This transaction physically deletes the detail records.

 Notes:
 1) If "Include Deleted Only" = Yes, then only those records marked
    "deleted" will be selected.
    If "Include Deleted Only" = No, then all records will be selected for
    delete.
 2) If the detail record has been picked or x-referenced, then it will not be
    selected for delete, regardless of the "Include Deleted Only" value.

 ============================================================================
 !*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

&SCOPED-DEFINE simulation true
/* PREPROCESSOR USED FOR REPORT'S WITH SIMULATION OPTION */

define variable shipfrom_from like rcs_shipfrom  no-undo.
define variable shipfrom_to   like rcs_shipfrom  no-undo.
define variable shipto_from   like rcs_shipto    no-undo.
define variable shipto_to     like rcs_shipto    no-undo.
define variable rlseid_from   like rcsd_rlse_id  no-undo.
define variable rlseid_to     like rcsd_rlse_id  no-undo.
define variable custjob_from  like rcsd_cust_job no-undo.
define variable custjob_to    like rcsd_cust_job no-undo.
define variable custseq_from  like rcsd_cust_seq no-undo.
define variable custseq_to    like rcsd_cust_seq no-undo.
define variable custref_from  like rcsd_custref  no-undo
                              label "Line Item Cust Ref".
define variable custref_to    like rcsd_custref  no-undo.
define variable modelyr_from  like rcsd_modelyr  no-undo.
define variable modelyr_to    like rcsd_modelyr  no-undo.
define variable cust_ref_from like rcsd_cust_ref no-undo.
define variable cust_ref_to   like rcsd_cust_ref no-undo.
define variable part_from     like rcsd_part     no-undo.
define variable part_to       like rcsd_part     no-undo.
define variable po_from       like rcsd_cust_po  no-undo.
define variable po_to         like rcsd_cust_po  no-undo.
define variable order_from    like rcsd_order    no-undo.
define variable order_to      like rcsd_order    no-undo.
define variable status_from   like rcsd_status   no-undo.
define variable status_to     like rcsd_status   no-undo.
define variable date_from     like rcsd_date
                              label "Ship/Delivery Date" no-undo.
define variable date_to       like rcsd_date     no-undo.
define variable time_from     like rcsd_time     no-undo.
define variable time_to       like rcsd_time     no-undo.
define variable inc_del_only  like mfc_logical   no-undo
                              label "Include Deleted Only" initial yes.
define variable update_yn     like mfc_logical
                              label "Update"     no-undo.
define variable l_from_name   like ad_name       no-undo.
define variable l_cust_name   like ad_name       no-undo.
define variable l_cust_id     like cm_addr       no-undo.
define variable l_to_name     like ad_name       no-undo.
define variable l_shipto_ref  like ad_ref        no-undo.
define variable l_pt_um       like pt_um         no-undo.
define variable dt_from       as date            no-undo.
define variable dt_to         as date            no-undo.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
shipfrom_from      colon 20
   shipfrom_to        colon 45 label {t001.i}
   shipto_from        colon 20
   shipto_to          colon 45 label {t001.i}
   rlseid_from        colon 20                view-as fill-in size 20 by 1
   rlseid_to          colon 45 label {t001.i} view-as fill-in size 20 by 1
   custjob_from       colon 20                view-as fill-in size 20 by 1
   custjob_to         colon 45 label {t001.i} view-as fill-in size 20 by 1
   custseq_from       colon 20                view-as fill-in size 20 by 1
   custseq_to         colon 45 label {t001.i} view-as fill-in size 20 by 1
   custref_from       colon 20                view-as fill-in size 20 by 1
   custref_to         colon 45 label {t001.i} view-as fill-in size 20 by 1
   modelyr_from       colon 20                view-as fill-in size 20 by 1
   modelyr_to         colon 45 label {t001.i} view-as fill-in size 20 by 1
   cust_ref_from      colon 20                view-as fill-in size 20 by 1
   cust_ref_to        colon 45 label {t001.i} view-as fill-in size 20 by 1
   part_from          colon 20
   part_to            colon 45 label {t001.i}
   order_from         colon 20
   order_to           colon 45 label {t001.i}
   po_from            colon 20                view-as fill-in size 20 by 1
   po_to              colon 45 label {t001.i} view-as fill-in size 20 by 1
   status_from        colon 20
   status_to          colon 45 label {t001.i}
   date_from          colon 20
   time_from          no-label
   date_to            colon 45 label {t001.i}
   time_to            no-label
   skip(1)
   inc_del_only       colon 40
   update_yn          colon 40
   skip
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   rcsd_shipfrom   colon 15
   l_from_name     no-label
   l_cust_id       colon 15
   l_cust_name     no-label
   rcsd_shipto     colon 15
   l_to_name       no-label
   rcsd_rlse_id    colon 15
with STREAM-IO /*GUI*/  frame rcsd-header side-labels width 132 attr-space.

/* SET EXTERNAL LABELS */
setFrameLabels(frame rcsd-header:handle).

FORM /*GUI*/ 
   rcsd_cust_job   column-label "Customer Job!Customer Sequence"
   rcsd_part       column-label "Item!Status"
   l_pt_um
   rcsd_order      column-label "Order!Line!Model Yr"
   rcsd_cust_po    column-label "PO Number!Customer Ref!Line Item Cust Ref"
                   view-as fill-in size 20 by 1
   rcsd_dock       column-label "Customer Dock!Line Feed"
                   view-as fill-in size 20 by 1
   rcsd_discr_qty  column-label "Quantity!Cum Quantity"
with STREAM-IO /*GUI*/  frame rcsd-details down width 132.

/* SET EXTERNAL LABELS */
setFrameLabels(frame rcsd-details:handle).

repeat with frame a:

   if shipfrom_to = hi_char then shipfrom_to = "".
   if shipto_to   = hi_char then shipto_to   = "".
   if rlseid_to   = hi_char then rlseid_to   = "".
   if custjob_to  = hi_char then custjob_to  = "".
   if custseq_to  = hi_char then custseq_to  = "".
   if custref_to  = hi_char then custref_to  = "".
   if modelyr_to  = hi_char then modelyr_to  = "".
   if cust_ref_to = hi_char then cust_ref_to = "".
   if part_to     = hi_char then part_to     = "".
   if time_to     = hi_char then time_to     = "".
   if dt_from     = low_date then date_from  = ?.
   if dt_to       = hi_date then date_to     = ?.
   if order_to    = hi_char then order_to    = "".
   if po_to       = hi_char then po_to       = "".
   if status_to   = hi_char then status_to   = "".

   update
      shipfrom_from
      shipfrom_to
      shipto_from
      shipto_to
      rlseid_from
      rlseid_to
      custjob_from
      custjob_to
      custseq_from
      custseq_to
      custref_from
      custref_to
      modelyr_from
      modelyr_to
      cust_ref_from
      cust_ref_to
      part_from
      part_to
      order_from
      order_to
      po_from
      po_to
      status_from
      status_to
      date_from
      time_from
      date_to
      time_to
      inc_del_only
      update_yn
   with frame a.

   bcdparm = "".
   {mfquoter.i shipfrom_from }
   {mfquoter.i shipfrom_to   }
   {mfquoter.i shipto_from   }
   {mfquoter.i shipto_to     }
   {mfquoter.i rlseid_from   }
   {mfquoter.i rlseid_to     }
   {mfquoter.i custjob_from  }
   {mfquoter.i custjob_to    }
   {mfquoter.i custseq_from  }
   {mfquoter.i custseq_to    }
   {mfquoter.i custref_from  }
   {mfquoter.i custref_to    }
   {mfquoter.i modelyr_from  }
   {mfquoter.i modelyr_to    }
   {mfquoter.i cust_ref_from }
   {mfquoter.i cust_ref_to   }
   {mfquoter.i part_from     }
   {mfquoter.i part_to       }
   {mfquoter.i order_from    }
   {mfquoter.i order_to      }
   {mfquoter.i po_from       }
   {mfquoter.i po_to         }
   {mfquoter.i status_from   }
   {mfquoter.i status_to     }
   {mfquoter.i date_from     }
   {mfquoter.i time_from     }
   {mfquoter.i date_to       }
   {mfquoter.i time_to       }
   {mfquoter.i inc_del_only  }
   {mfquoter.i update_yn     }

   if shipfrom_to = "" then shipfrom_to = hi_char.
   if shipto_to   = "" then shipto_to   = hi_char.
   if rlseid_to   = "" then rlseid_to   = hi_char.
   if custjob_to  = "" then custjob_to  = hi_char.
   if custseq_to  = "" then custseq_to  = hi_char.
   if custref_to  = "" then custref_to  = hi_char.
   if modelyr_to  = "" then modelyr_to  = hi_char.
   if cust_ref_to = "" then cust_ref_to = hi_char.
   if part_to     = "" then part_to     = hi_char.
   if order_to    = "" then order_to    = hi_char.
   if po_to       = "" then po_to       = hi_char.
   if status_to   = "" then status_to   = hi_char.
   if time_to     = "" then time_to     = hi_char.


   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i
      &printType = "printer"
      &printWidth = 132
      &pagedFlag = " "
      &stream = " "
      &appendToFile = " "
      &streamedOutputToTerminal = " "
      &withBatchOption = "yes"
      &displayStatementType = 1
      &withCancelMessage = "yes"
      &pageBottomMargin = 6
      &withEmail = "yes"
      &withWinprint = "yes"
      &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.


   {mfphead.i}

   if date_from = ? then
      dt_from = low_date.
   else
      dt_from = date_from.

   if date_to = ?
   then
      dt_to = hi_date.
   else
      dt_to = date_to.

   for each rcsd_det exclusive-lock
      where rcsd_shipfrom >= shipfrom_from
      and   rcsd_shipfrom <= shipfrom_to
      and   rcsd_shipto >= shipto_from
      and   rcsd_shipto <= shipto_to
      and   rcsd_rlse_id >= rlseid_from
      and   rcsd_rlse_id <= rlseid_to
      and   rcsd_date >= dt_from
      and   rcsd_date <= dt_to
      and   rcsd_time >= time_from
      and   rcsd_time <= time_to
      and   rcsd_cust_job >= custjob_from
      and   rcsd_cust_job <= custjob_to
      and   rcsd_cust_seq >= custseq_from
      and   rcsd_cust_seq <= custseq_to
      and   rcsd_custref  >= custref_from
      and   rcsd_custref  <= custref_to
      and   rcsd_modelyr  >= modelyr_from
      and   rcsd_modelyr  <= modelyr_to
      and   rcsd_cust_ref >= cust_ref_from
      and   rcsd_cust_ref <= cust_ref_to
      and   rcsd_part >= part_from
      and   rcsd_part <= part_to
      and   rcsd_status >= status_from
      and   rcsd_status <= status_to
      and   rcsd_cust_po >= po_from
      and   rcsd_cust_po <= po_to
      and   rcsd_order >= order_from
      and   rcsd_order <= order_to
      and   (not rcsd_picked and
             not rcsd_x_referenced)
      and   (not inc_del_only or
             (inc_del_only and rcsd_deleted))
      break by rcsd_shipfrom
            by rcsd_shipto
            by rcsd_rlse_id
      with frame rcsd-details down:

      /* PRINT SCHEDULE HEADING */
      if first-of(rcsd_rlse_id)
      then do:

         for first si_mstr
            where si_site = rcsd_shipfrom
         no-lock:
            l_from_name = si_desc.
         end.

         for first ad_mstr
            where ad_addr = rcsd_shipto
            no-lock:
         end.

         assign
            l_cust_id    = ad_addr
            l_cust_name  = ad_name
            l_to_name    = ad_name
            l_shipto_ref = ad_ref.

         if ad_type = "dock" or
            ad_type = "ship-to"
         then do:
            for first ad_mstr no-lock
               where ad_addr = l_shipto_ref:
               assign
                  l_cust_id = ad_addr
                  l_cust_name = ad_name.
            end.
         end.

         if page-size - line-counter < 5
         then
            page.

         display
            rcsd_shipfrom
            l_from_name
            l_cust_id
            l_cust_name
            rcsd_shipto
            l_to_name
            rcsd_rlse_id
         with frame rcsd-header STREAM-IO /*GUI*/ .

         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


      end.  /* if first-of(rcsd_rlse_id) */

      if page-size - line-counter < 2
      then
         page.

      /* PRINT SCHEDULE DETAIL */
      display
         rcsd_cust_job
         rcsd_part
         l_pt_um
         rcsd_order
         rcsd_cust_po
         rcsd_dock
         rcsd_discr_qty
         rcsd_delete WITH STREAM-IO /*GUI*/ .

      down 1.

      display
         rcsd_cust_seq     @ rcsd_cust_job
         string(rcsd_line) @ rcsd_order
         rcsd_cust_ref     @ rcsd_cust_po
         rcsd_status       @ rcsd_part
         rcsd_line_feed    @ rcsd_dock WITH STREAM-IO /*GUI*/ .

      down 1.
      display
         rcsd_modelyr      @ rcsd_order
         rcsd_custref      @ rcsd_cust_po WITH STREAM-IO /*GUI*/ .

      down 2.

      if update_yn
      then
         delete rcsd_det.

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end. /* FOR EACH RCSD_DET */

   /* REPORT TRAILER */
   {mfrtrail.i}
end.
